
<?php
use yii\helpers\Url;
use yii\widgets\ActiveForm;

?>
<!-- topbar ends -->
<div class="row borB">
    <div class="container lh30">
        <a class="topNav"  href="<?=Url::toRoute('/system/site/index')?>"><img src="<?=Yii::getAlias('@web/backend/img/home/home.png');?>" alt="首页"/>返回首页</a>
    </div>
</div>
<div class="row nav-brand-bg">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li><a href="<?=Url::toRoute('shop/index')?>">线上店铺</a></li>
            <li class="active"><a href="<?=Url::toRoute('shop/servicelist')?>">线上项目</a></li>
        </ul>
    </div>
</div>
<!--  添加     -->
<?php if(!isset($data)){?>
<div class="container mt20">
    <?php ActiveForm::begin([
        'action'=>Url::toRoute('shop/serviceadd'),
        'options' => [
            'class' => 'form-horizontal',
            'method' => 'post',
            'enctype' => 'multipart/form-data',
        ],
    ])?>
        <div class="itemList clearfix">
            <label class="item-name">名称</label>
            <div class="item-txt">
                <input type="text" name="service_name">
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">图片</label>
            <div class="item-txt">
                <input type="file" name="service_cover">
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">价格</label>
            <div class="item-txt">
                <input type="text" name="service_price" />
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">规格</label>
            <div class="item-txt">
                <input type="text" name="service_unit" />
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">状态</label>
            <div class="item-txt">
                <select style="width: 240px;" name="service_is_sell">
                    <option value="1">上架</option>
                    <option value="-1">下架</option>
                </select>
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">详情</label>
            <div class="item-txt">
                <textarea id="editor" style="width:600px;height:300px;" name="service_intro">欢迎您到店体验！</textarea>
            </div>
        </div>
        <div style="padding-left: 156px;">
            <input class="btnBg mr10" type="submit" value="保存">
            <input class="btnBg mr10" type="reset" value="取消">
        </div>
    <?php ActiveForm::end();?>
</div>
<?php }else{?>
<!--  修改     -->
<div class="container mt20">
    <?php ActiveForm::begin([
        'action'=>Url::toRoute('shop/serviceedit'),
        'options' => [
            'class' => 'form-horizontal',
            'method' => 'post',
            'enctype' => 'multipart/form-data',
        ],
    ])?>
        <div class="itemList clearfix">
            <label class="item-name">名称</label>
            <div class="item-txt">
                <input type="hidden" name="id" value="<?=$data['id'] ?>">
                <input type="text" name="service_name" value="<?=$data['name'] ?>">
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">图片</label>
            <div class="item-txt">
                <img src="<?=Yii::$app->params['imgUrl'].$data['cover'] ?>" style="width: 400px; height:200px;"/>
                <input type="hidden" name="old_cover" value="<?=$data['cover'] ?>">
                <input type="file" name="service_cover">
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">价格</label>
            <div class="item-txt">
                <input type="text" name="service_price" value="<?=$data['price'] ?>"/>
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">规格</label>
            <div class="item-txt">
                <input type="text" name="service_unit" value="<?=$data['unit'] ?>"/>
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">状态</label>
            <div class="item-txt">
                <select style="width: 240px;" name="service_is_sell">
                    <option value="1" <?php if($data['is_sell'] == 1){?>select="select"<?php }?>>上架</option>
                    <option value="-1" <?php if($data['is_sell'] == -1){?>select="select"<?php }?>>下架</option>
                </select>
            </div>
        </div>
        <div class="itemList clearfix">
            <label class="item-name">详情</label>
            <div class="item-txt">
                <textarea id="editor" style="width:600px;height:300px;" name="service_intro">
                <?=$data['intro'] ?>
                </textarea>
            </div>
        </div>
        <div style="padding-left: 156px;">
            <a class="btnBg ml20" style=" height: 40px;">
                <input class="commit" type="submit" value="保存" style="height: 40px;line-height: 40px; background: 0; border: 0;" onclick="return checkTest">
            </a>
            <a class="btnBg bg_rest ml20" href="<?=Url::toRoute('/openapi/shop/servicelist')?>" style=" height: 40px;">
                <input class="" type="reset" value="取消" style="height: 40px;line-height: 40px; background: 0; border: 0; ">
            </a>
        </div>
    <?php ActiveForm::end();?>
</div>
<?php }?>
<?php 
$this->registerJsFile('@web/ueditor/utf8-php/ueditor.config.js');
$this->registerJsFile('@web/ueditor/utf8-php/ueditor.all.min.js');
$this->registerJsFile('@web/system/shop/service.js');
?>

